<?php
/** 
 * Physician_group_model
 * This class handles model work necessary for Physician_group Crud and List operations 
 * 
 * @author Ray Nowell
 *	
 */ 
class Physician_group_model extends MY_Model {

	function Physician_group_model()
	{
		parent::MY_Model();
	}
	
	function Add_physician_group($data)
	{
		return $this->db->insert('physician_group', $data);
	}
	
	function Update_physician_group($data)
	{				
		$this->db->where('physician_group_id',element('physician_group_id', $data));
		$this->db->where('facility_id',$this->facility_id);
		
		return $this->db->update('physician_group',$data);
	}
	
	function Delete_physician_group()
	{
		$ret_val = $this->delete_record('physician_group','physician_group_id');
		return $ret_val;	
	}
	/*
	 * Returns a list of current physician_groups
	 * @todo must filter by logged in user
	 */
	function get_physician_group_list()
	{
		$select_fields = "physician_group_id
							,`group`
							,CASE active WHEN 1 THEN 'Yes' Else 'No' END as active";
										 //,CASE active WHEN 0 THEN 'No' WHEN 1 THEN 'Yes' ELSE '' END AS Active";
		//Get the query results for the clinical physician_groups
		$this->db->select($select_fields,false);
		$this->db->from('physician_group');
		$this->db->where('facility_id',$this->facility_id);
		$this->db->order_by('`group`');
		$query = $this->db->get();
				
		return $query->result_array();
	}

	/*
	 * Returns a single physician_group record based on Cliincal Physician_group Id passed 
	 */
	function get_physician_group_record($physician_group_id)
	{
		$query = $this->db->limit(1)->get_where('physician_group', array('physician_group_id' => $physician_group_id)); 
		return $query->row();
	}
	/*
	 * Returns a single physician_group record based on Cliincal Pharmacist Id passed 
	 */
	function get_physician_group_id_record($physician_group_id)
	{
		$query = $this->db->limit(1)->get_where('physician_group', array('physician_group_id' => $physician_group_id,
		 																'facility_id'	=>	$this->facility_id));
		return $query->row();
	}
}

/* End of file physician_group_model.php */
/* Location: ./system/application/models/physician_group_model.php */